Skip to content

Proposal: Multiple Snapshot Formats#30

Open
avivkeller wants to merge 1 commit intomainfrom
proposal/multiple-snapshot-formats
Open

Proposal: Multiple Snapshot Formats#30
avivkeller wants to merge 1 commit intomainfrom
proposal/multiple-snapshot-formats

Conversation

@avivkeller
Copy link
Copy Markdown
Member

@avivkeller avivkeller commented Apr 8, 2026

As discussed in today's meeting, I feel that we should apply the same logic that we do to finding tests that we do to finding snapshots.

As for generating them, I think we should generate the snapshot either:

  • Always CJS (Status Quo)
  • Always ESM
  • Use module from package.json
  • Use --experimental-snapshot-format=[cjs|mjs|json]
  • Use type of test (e.g. .test.cjs -> .snapshot.cjs)

There are plenty of times where it would be beneficial to support JSON snapshots (and ESM). For instance, if a non-JS runtime needs to access these files, they may not have the parsing capability to deconstruct a CJS file, but they will have the ability to read a JSON fiel.

Copilot AI review requested due to automatic review settings April 8, 2026 21:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a written proposal to extend the Node.js test runner’s snapshot discovery to support multiple snapshot file extensions, analogous to how test files are discovered.

Changes:

  • Introduces a new proposal document describing multi-extension snapshot resolution behavior.
  • Defines an example resolution order for snapshot extensions.
  • Provides an example error when multiple candidate snapshot files are found.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants